package com.proposition.support.config;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.Configuration;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Locale;

/**
 * 集成Shiro标签
 * @author Administrator
 */
@Component
public class ShiroTagFreeMarkerConfigurer implements InitializingBean {

	@Autowired
	private Configuration configuration;

	@Override
	public void afterPropertiesSet() throws Exception {
		// 加上这句后，可以在页面上使用shiro标签
		configuration.setSharedVariable("shiro", new ShiroTags());
		configuration.setTagSyntax(0);
		configuration.setDefaultEncoding("UTF-8");
		configuration.setURLEscapingCharset("UTF-8");
		configuration.setLocale(Locale.SIMPLIFIED_CHINESE);
		configuration.setBooleanFormat("true,false");
		configuration.setDateTimeFormat("yyyy-MM-dd HH:mm:ss");
		configuration.setDateFormat("yyyy-MM-dd");
		configuration.setTimeFormat("HH:mm:ss");
		configuration.setNumberFormat("0.######");
		configuration.setWhitespaceStripping(true);
	}
}
